Question I have is on using the 'eval_' command. The DXL that I am running performs a number of maintenance features to the DOORS project. To minimize the updates needed to this code, I am using a custom module to store simple maintenance functions that the DXL reads in allowing the user to select which maintenance action to run. I use the 'eval_'command to run the selected code. For the most part this is working well. However, the one downside that I am seeing is that the code that is inserted in from the custom module does not recognize variables that are already defined. How do I get this inserted code to see these variables? Mike.P.Adams - Tue May 31 11:17:27 EDT 2016 |
Re: Using the 'eval_" command You have to embed the variable into the string. I will show this by simple example pseudo code. string yourvariable ="test"
string ToRun= "int i =0 ; string yourvariable =" yourvariable " ; print i \" and \" yourvariable "" eval_( ToRun ) //You might say, you pass yourvariable into the ToRun string. |
Re: Using the 'eval_" command The eval_ command is executing a new dxl script on its own right, like from a menu option, or for a new instance of doors, or from layout dxl etc. So as you cannot pass parameters from one script to another or from one instance of doors to another or from one layout to another, you cannot pass parameters from your calling program to eval. Therefore you have to build them on the runtime. Consider the following example.
int a = 3
int b = 5
int c = a + b
eval_("print \"c=" c "\"")
The code will print "c=8". The parameter of c is passed at the runtime to evel_ via the construction of the string. This is the only way that you can pass parameters to eval_ so you need to construct your string correctly. It is not easy to pass a lot of parameters. It is not possible to pass skip lists or arrays or any other of objects. All the already declared addins are working fine within eval_, but anything outside of the eval_ string cannot be used. Try to put your code in a file and then execute that file with an "#include". This will make things simpler. |
Re: Using the 'eval_" command Costas..Aravidis - Wed Jun 01 01:13:47 EDT 2016 The eval_ command is executing a new dxl script on its own right, like from a menu option, or for a new instance of doors, or from layout dxl etc. So as you cannot pass parameters from one script to another or from one instance of doors to another or from one layout to another, you cannot pass parameters from your calling program to eval. Therefore you have to build them on the runtime. Consider the following example.
int a = 3
int b = 5
int c = a + b
eval_("print \"c=" c "\"")
The code will print "c=8". The parameter of c is passed at the runtime to evel_ via the construction of the string. This is the only way that you can pass parameters to eval_ so you need to construct your string correctly. It is not easy to pass a lot of parameters. It is not possible to pass skip lists or arrays or any other of objects. All the already declared addins are working fine within eval_, but anything outside of the eval_ string cannot be used. Try to put your code in a file and then execute that file with an "#include". This will make things simpler.
There is a way to pass objects, try the following code:
Skip sl = createString();
put(sl, "Test", "Test");
put(sl, "Test1", "Test1");
put(sl, "Test2", "Test2");
string toEval = "Skip sl = addr_("((addr_ sl) int)");\n"
toEval = toEval "string sz;\n"
toEval = toEval "for sz in sl do {print sz\"\\n\"}";
print toEval"\n\n";
eval_(toEval);
|